import 'package:cbec_app/generated/json/base/json_convert_content.dart';
import 'package:cbec_app/entity/home/content/new_image_ad_entity.dart';

NewImageAdEntity $NewImageAdEntityFromJson(Map<String, dynamic> json) {
  final NewImageAdEntity newImageAdEntity = NewImageAdEntity();
  final String? indicator = jsonConvert.convert<String>(json['indicator']);
  if (indicator != null) {
    newImageAdEntity.indicator = indicator;
  }
  final int? borderWidth = jsonConvert.convert<int>(json['border_width']);
  if (borderWidth != null) {
    newImageAdEntity.borderWidth = borderWidth;
  }
  final String? showMethod = jsonConvert.convert<String>(json['show_method']);
  if (showMethod != null) {
    newImageAdEntity.showMethod = showMethod;
  }
  final int? pageMargin = jsonConvert.convert<int>(json['page_margin']);
  if (pageMargin != null) {
    newImageAdEntity.pageMargin = pageMargin;
  }
  final String? count = jsonConvert.convert<String>(json['count']);
  if (count != null) {
    newImageAdEntity.count = count;
  }
  final String? imageFillStyle = jsonConvert.convert<String>(json['image_fill_style']);
  if (imageFillStyle != null) {
    newImageAdEntity.imageFillStyle = imageFillStyle;
  }
  final int? overlapHeight = jsonConvert.convert<int>(json['overlap_height']);
  if (overlapHeight != null) {
    newImageAdEntity.overlapHeight = overlapHeight;
  }
  final String? uuid = jsonConvert.convert<String>(json['uuid']);
  if (uuid != null) {
    newImageAdEntity.uuid = uuid;
  }
  final String? size = jsonConvert.convert<String>(json['size']);
  if (size != null) {
    newImageAdEntity.size = size;
  }
  final String? cornerType = jsonConvert.convert<String>(json['corner_type']);
  if (cornerType != null) {
    newImageAdEntity.cornerType = cornerType;
  }
  final List<NewImageAdSubEntry>? subEntry = (json['sub_entry'] as List<dynamic>?)?.map((e) => jsonConvert.convert<NewImageAdSubEntry>(e) as NewImageAdSubEntry).toList();
  if (subEntry != null) {
    newImageAdEntity.subEntry = subEntry;
  }
  final String? imageStyle = jsonConvert.convert<String>(json['image_style']);
  if (imageStyle != null) {
    newImageAdEntity.imageStyle = imageStyle;
  }
  final int? swipeTime = jsonConvert.convert<int>(json['swipe_time']);
  if (swipeTime != null) {
    newImageAdEntity.swipeTime = swipeTime;
  }
  return newImageAdEntity;
}

Map<String, dynamic> $NewImageAdEntityToJson(NewImageAdEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['indicator'] = entity.indicator;
  data['border_width'] = entity.borderWidth;
  data['show_method'] = entity.showMethod;
  data['page_margin'] = entity.pageMargin;
  data['count'] = entity.count;
  data['image_fill_style'] = entity.imageFillStyle;
  data['overlap_height'] = entity.overlapHeight;
  data['uuid'] = entity.uuid;
  data['size'] = entity.size;
  data['corner_type'] = entity.cornerType;
  data['sub_entry'] = entity.subEntry?.map((v) => v.toJson()).toList();
  data['image_style'] = entity.imageStyle;
  data['swipe_time'] = entity.swipeTime;
  return data;
}

extension NewImageAdEntityExtension on NewImageAdEntity {
  NewImageAdEntity copyWith({
    String? indicator,
    int? borderWidth,
    String? showMethod,
    int? pageMargin,
    String? count,
    String? imageFillStyle,
    int? overlapHeight,
    String? uuid,
    String? size,
    String? cornerType,
    List<NewImageAdSubEntry>? subEntry,
    String? imageStyle,
    int? swipeTime,
  }) {
    return NewImageAdEntity()
      ..indicator = indicator ?? this.indicator
      ..borderWidth = borderWidth ?? this.borderWidth
      ..showMethod = showMethod ?? this.showMethod
      ..pageMargin = pageMargin ?? this.pageMargin
      ..count = count ?? this.count
      ..imageFillStyle = imageFillStyle ?? this.imageFillStyle
      ..overlapHeight = overlapHeight ?? this.overlapHeight
      ..uuid = uuid ?? this.uuid
      ..size = size ?? this.size
      ..cornerType = cornerType ?? this.cornerType
      ..subEntry = subEntry ?? this.subEntry
      ..imageStyle = imageStyle ?? this.imageStyle
      ..swipeTime = swipeTime ?? this.swipeTime;
  }
}

NewImageAdSubEntry $NewImageAdSubEntryFromJson(Map<String, dynamic> json) {
  final NewImageAdSubEntry newImageAdSubEntry = NewImageAdSubEntry();
  final String? linkType = jsonConvert.convert<String>(json['link_type']);
  if (linkType != null) {
    newImageAdSubEntry.linkType = linkType;
  }
  final int? imageHeight = jsonConvert.convert<int>(json['image_height']);
  if (imageHeight != null) {
    newImageAdSubEntry.imageHeight = imageHeight;
  }
  final String? imageUrl = jsonConvert.convert<String>(json['image_url']);
  if (imageUrl != null) {
    newImageAdSubEntry.imageUrl = imageUrl;
  }
  final String? linkUrl = jsonConvert.convert<String>(json['link_url']);
  if (linkUrl != null) {
    newImageAdSubEntry.linkUrl = linkUrl;
  }
  final String? linkTitle = jsonConvert.convert<String>(json['link_title']);
  if (linkTitle != null) {
    newImageAdSubEntry.linkTitle = linkTitle;
  }
  final int? imageWidth = jsonConvert.convert<int>(json['image_width']);
  if (imageWidth != null) {
    newImageAdSubEntry.imageWidth = imageWidth;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    newImageAdSubEntry.title = title;
  }
  final int? linkId = jsonConvert.convert<int>(json['link_id']);
  if (linkId != null) {
    newImageAdSubEntry.linkId = linkId;
  }
  return newImageAdSubEntry;
}

Map<String, dynamic> $NewImageAdSubEntryToJson(NewImageAdSubEntry entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['link_type'] = entity.linkType;
  data['image_height'] = entity.imageHeight;
  data['image_url'] = entity.imageUrl;
  data['link_url'] = entity.linkUrl;
  data['link_title'] = entity.linkTitle;
  data['image_width'] = entity.imageWidth;
  data['title'] = entity.title;
  data['link_id'] = entity.linkId;
  return data;
}

extension NewImageAdSubEntryExtension on NewImageAdSubEntry {
  NewImageAdSubEntry copyWith({
    String? linkType,
    int? imageHeight,
    String? imageUrl,
    String? linkUrl,
    String? linkTitle,
    int? imageWidth,
    String? title,
    int? linkId,
  }) {
    return NewImageAdSubEntry()
      ..linkType = linkType ?? this.linkType
      ..imageHeight = imageHeight ?? this.imageHeight
      ..imageUrl = imageUrl ?? this.imageUrl
      ..linkUrl = linkUrl ?? this.linkUrl
      ..linkTitle = linkTitle ?? this.linkTitle
      ..imageWidth = imageWidth ?? this.imageWidth
      ..title = title ?? this.title
      ..linkId = linkId ?? this.linkId;
  }
}
